package com.example.gorannet;

import java.util.ArrayList;
import java.util.List;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MyChoices extends Fragment implements OnItemClickListener {

	private FragmentManager manager;
	private FragmentTransaction transaction;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) 
	{
		View view = inflater.inflate(R.layout.mychoicelist,container, false);
		ListView listView = (ListView)view.findViewById(R.id.lv11);
        List<String> listData = new ArrayList<String>();
        listData.add("Tickets");
        listData.add("GCM");
        listData.add("Settings");
        listView.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.listItem, listData));
        listView.setOnItemClickListener(this);
        
		manager = getFragmentManager();

		
		return view;
	}
	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		
		if(arg2 == 0)
		{
			transaction = manager.beginTransaction();
			transaction.replace(R.id.fragmentcontainer2, new Tickets());
			transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
			transaction.addToBackStack(getTag());
			transaction.commit();	
		}
		if(arg2 == 1)
		{
			
			transaction = manager.beginTransaction();
			transaction.replace(R.id.fragmentcontainer2, new GCMmessages());
			transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
			transaction.addToBackStack(getTag());
			transaction.commit();
		}
		if(arg2 == 2)
		{					
			transaction = manager.beginTransaction();
			transaction.replace(R.id.fragmentcontainer2, new AppSettings());
			transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
			transaction.addToBackStack(getTag());
			transaction.commit();
		}
	}

}